package com.project.lk.nurseapp.ticket.presenter;

import com.project.lk.nurseapp.base.BaseApi;
import com.project.lk.nurseapp.base.BasePresenter;
import com.project.lk.nurseapp.base.ModelPresenterBridge;
import com.project.lk.nurseapp.ticket.model.TicketItemBean;
import com.project.lk.nurseapp.ticket.model.TicketListModel;

import java.util.List;

/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class TicketPresenter extends BasePresenter<ITicketView> implements ModelPresenterBridge{
    TicketListModel ticketListModel;
    public TicketPresenter(ITicketView view) {
        addView(view);
        ticketListModel=new TicketListModel();
        ticketListModel.setBridge(this);
    }

    public List<TicketItemBean> getList(){
        return ticketListModel.getmList();
    }

    public void refresh(String url){
        ticketListModel.refresh();
        ticketListModel.postLoadJson(url);
    }

    public void loadMore(String url){
        ticketListModel.loadMore();
        ticketListModel.postLoadJson(url);
    }

    @Override
    public void bridge(int action, List list) {
        if (view != null) {
            switch (action) {
                case BaseApi.show_list:
                    view.showList();
                    break;
                case BaseApi.fail:
                    view.fail();
                    break;
                case BaseApi.noMore:
                    view.noMore();
                    break;
            }
        }
    }
}
